library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
The data to process is described in:
https://zenodo.org/record/4156647#.Y1bSF3bMKUk
IR Saliva Testing Dataset
10.5281/zenodo.4156647 https://doi.org/10.5281/zenodo.4156647
I added a column to the data identifying the repeated experiments.
SalivaIR <- as.data.frame(read_excel("~/GitHub/FCA/Data/SalivaThermal_Source_Data_2.xlsx"))
SalivaIR_set1 <- subset(SalivaIR,RepID==1)
rownames(SalivaIR_set1) <- SalivaIR_set1$ID
SalivaIR_set1$RepID <- NULL
SalivaIR_set1$ID <- NULL
SalivaIR_set1$Ct <- NULL
SalivaIR_set2 <- subset(SalivaIR,RepID==2)
rownames(SalivaIR_set2) <- SalivaIR_set2$ID
SalivaIR_set2$RepID <- NULL
SalivaIR_set2$ID <- NULL
SalivaIR_set2$Ct <- NULL
SalivaIR_set3 <- subset(SalivaIR,RepID==3)
rownames(SalivaIR_set3) <- SalivaIR_set3$ID
SalivaIR_set3$RepID <- NULL
SalivaIR_set3$ID <- NULL
SalivaIR_set3$Ct <- NULL
SalivaIR_Avg <- (SalivaIR_set1 + SalivaIR_set2 + SalivaIR_set3)/3
colnames(SalivaIR_Avg) <- paste("V",colnames(SalivaIR_Avg),sep="_")
SalivaIR_Avg$class <- 1*(str_detect(rownames(SalivaIR_Avg),"P"))
pander::pander(table(SalivaIR_Avg$class))
| 0 | 1 |
|---|---|
| 30 | 31 |
studyName <- "IRSaliva"
dataframe <- SalivaIR_Avg
outcome <- "class"
TopVariables <- 10
thro <- 0.80
cexheat = 0.15
Some libraries
library(psych)
library(whitening)
library("vioplot")
library("rpart")
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
| rows | col |
|---|---|
| 61 | 251 |
pander::pander(table(dataframe[,outcome]))
| 0 | 1 |
|---|---|
| 30 | 31 |
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1500
Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples
dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData
numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000
if (!largeSet)
{
hm <- heatMaps(data=dataframeScaled[1:numsub,],
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.999994
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> Included: 224 , Uni p: 0.04988877 , Uncorrelated Base: 1 , Outcome-Driven Size: 0 , Base Size: 1
#>
#>
1 <R=1.000,thr=0.900,N= 224>, Top: 1( 223 )[ 1 : 1 Fa= 1 : 0.900 ]( 1 , 223 , 0 ),<|>Tot Used: 224 , Added: 223 , Zero Std: 0 , Max Cor: 1.000
#>
2 <R=1.000,thr=0.900,N= 224>, Top: 3( 93 )[ 1 : 3 Fa= 4 : 0.900 ]( 3 , 154 , 1 ),<|>Tot Used: 224 , Added: 154 , Zero Std: 0 , Max Cor: 1.000
#>
3 <R=1.000,thr=0.900,N= 224>, Top: 10( 24 )=( 1 )[ 2 : 10 Fa= 14 : 0.935 ]( 10 , 131 , 4 ),<|>Tot Used: 224 , Added: 131 , Zero Std: 0 , Max Cor: 1.000
#>
4 <R=1.000,thr=0.900,N= 224>, Top: 18( 3 )[ 1 : 18 Fa= 32 : 0.900 ]( 18 , 147 , 14 ),<|>Tot Used: 224 , Added: 147 , Zero Std: 0 , Max Cor: 1.000
#>
5 <R=1.000,thr=0.900,N= 224>, Top: 35( 5 )[ 1 : 35 Fa= 67 : 0.900 ]( 35 , 134 , 32 ),<|>Tot Used: 224 , Added: 134 , Zero Std: 0 , Max Cor: 0.999
#>
6 <R=0.999,thr=0.900,N= 224>, Top: 34( 8 )[ 1 : 34 Fa= 101 : 0.900 ]( 34 , 96 , 67 ),<|>Tot Used: 224 , Added: 96 , Zero Std: 0 , Max Cor: 0.998
#>
7 <R=0.998,thr=0.900,N= 224>, Top: 25( 2 )[ 1 : 25 Fa= 126 : 0.900 ]( 25 , 47 , 101 ),<|>Tot Used: 224 , Added: 47 , Zero Std: 0 , Max Cor: 0.996
#>
8 <R=0.996,thr=0.900,N= 224>, Top: 11( 3 )[ 1 : 11 Fa= 137 : 0.900 ]( 11 , 15 , 126 ),<|>Tot Used: 224 , Added: 15 , Zero Std: 0 , Max Cor: 0.934
#>
9 <R=0.934,thr=0.900,N= 224>, Top: 2( 1 )[ 1 : 2 Fa= 139 : 0.900 ]( 2 , 2 , 137 ),<|>Tot Used: 224 , Added: 2 , Zero Std: 0 , Max Cor: 0.897
#>
10 <R=0.897,thr=0.800,N= 76>, Top: 33( 1 )[ 1 : 33 Fa= 145 : 0.800 ]( 29 , 39 , 139 ),<|>Tot Used: 224 , Added: 39 , Zero Std: 0 , Max Cor: 0.994
#>
11 <R=0.994,thr=0.900,N= 30>, Top: 15( 1 )[ 1 : 15 Fa= 151 : 0.900 ]( 15 , 15 , 145 ),<|>Tot Used: 224 , Added: 15 , Zero Std: 0 , Max Cor: 0.970
#>
12 <R=0.970,thr=0.900,N= 30>, Top: 5( 1 )[ 1 : 5 Fa= 153 : 0.900 ]( 5 , 5 , 151 ),<|>Tot Used: 224 , Added: 5 , Zero Std: 0 , Max Cor: 0.993
#>
13 <R=0.993,thr=0.900,N= 30>, Top: 3( 1 )[ 1 : 3 Fa= 153 : 0.900 ]( 3 , 3 , 153 ),<|>Tot Used: 224 , Added: 3 , Zero Std: 0 , Max Cor: 0.940
#>
14 <R=0.940,thr=0.900,N= 30>, Top: 1( 1 )[ 1 : 1 Fa= 153 : 0.900 ]( 1 , 1 , 153 ),<|>Tot Used: 224 , Added: 1 , Zero Std: 0 , Max Cor: 0.883
#>
15 <R=0.883,thr=0.800,N= 21>, Top: 9( 2 )[ 1 : 9 Fa= 154 : 0.800 ]( 9 , 11 , 153 ),<|>Tot Used: 224 , Added: 11 , Zero Std: 0 , Max Cor: 0.960
#>
16 <R=0.960,thr=0.900,N= 4>, Top: 2( 1 )[ 1 : 2 Fa= 154 : 0.900 ]( 2 , 2 , 154 ),<|>Tot Used: 224 , Added: 2 , Zero Std: 0 , Max Cor: 0.979
#>
17 <R=0.979,thr=0.900,N= 4>, Top: 2( 1 )[ 1 : 2 Fa= 154 : 0.900 ]( 2 , 2 , 154 ),<|>Tot Used: 224 , Added: 2 , Zero Std: 0 , Max Cor: 0.927
#>
18 <R=0.927,thr=0.900,N= 4>, Top: 1( 1 )[ 1 : 1 Fa= 154 : 0.900 ]( 1 , 1 , 154 ),<|>Tot Used: 224 , Added: 1 , Zero Std: 0 , Max Cor: 0.848
#>
19 <R=0.848,thr=0.800,N= 2>, Top: 1( 1 )[ 1 : 1 Fa= 154 : 0.800 ]( 1 , 1 , 154 ),<|>Tot Used: 224 , Added: 1 , Zero Std: 0 , Max Cor: 0.799
#>
20 <R=0.799,thr=0.800,N= 2>
#>
[ 20 ], 0.7985213 Decor Dimension: 224 Nused: 224 . Cor to Base: 223 , ABase: 1 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
5.5
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
0.0328
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
5.08
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
0.843
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPSTM <- attr(DEdataframe,"UPSTM")
gplots::heatmap.2(1.0*(abs(UPSTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after IDeA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.7985213
if (nrow(dataframe) < 1000)
{
classes <- unique(dataframe[1:numsub,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
datasetframe.umap = umap(scale(dataframe[1:numsub,varlist]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
}
if (nrow(dataframe) < 1000)
{
datasetframe.umap = umap(scale(DEdataframe[1:numsub,varlistc]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After IDeA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
}
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
100 : V_1064 200 : V_854
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
100 : La_V_1064 200 : La_V_854
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| V_908 | 0.221 | 0.128 | 0.261 | 0.117 | 0.579 | 0.596 |
| V_906 | 0.220 | 0.127 | 0.261 | 0.117 | 0.585 | 0.596 |
| V_904 | 0.220 | 0.127 | 0.261 | 0.117 | 0.592 | 0.596 |
| V_892 | 0.219 | 0.127 | 0.261 | 0.121 | 0.626 | 0.596 |
| V_890 | 0.219 | 0.127 | 0.261 | 0.121 | 0.616 | 0.596 |
| V_888 | 0.219 | 0.127 | 0.261 | 0.122 | 0.603 | 0.596 |
| V_912 | 0.223 | 0.129 | 0.263 | 0.117 | 0.604 | 0.595 |
| V_910 | 0.222 | 0.128 | 0.262 | 0.117 | 0.587 | 0.595 |
| V_896 | 0.220 | 0.127 | 0.261 | 0.120 | 0.620 | 0.595 |
| V_894 | 0.219 | 0.127 | 0.261 | 0.121 | 0.625 | 0.595 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
pander::pander(finalTable)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| La_V_1048 | 3.02e-04 | 4.30e-03 | -3.99e-03 | 3.15e-03 | 0.8394 | 0.841 |
| La_V_1226 | 1.27e-03 | 1.55e-03 | 2.82e-03 | 1.49e-03 | 0.8181 | 0.803 |
| La_V_902 | -2.20e-06 | 1.72e-05 | -2.01e-05 | 2.28e-05 | 0.6481 | 0.772 |
| La_V_1110 | 4.48e-03 | 1.90e-02 | 1.95e-02 | 1.21e-02 | 0.1718 | 0.765 |
| La_V_1196 | 5.71e-05 | 2.44e-04 | 2.81e-04 | 3.86e-04 | 0.2432 | 0.749 |
| La_V_1034 | 2.35e-04 | 1.19e-03 | -6.05e-04 | 5.33e-04 | 0.9599 | 0.742 |
| La_V_848 | 2.51e-04 | 2.17e-03 | -6.34e-04 | 9.82e-04 | 0.1939 | 0.734 |
| La_V_1032 | 3.10e-03 | 9.45e-03 | 9.68e-03 | 7.58e-03 | 0.9605 | 0.733 |
| La_V_892 | -5.57e-06 | 4.67e-06 | -1.94e-06 | 5.19e-06 | 0.9945 | 0.732 |
| La_V_1252 | -5.51e-03 | 8.34e-03 | -1.32e-02 | 1.29e-02 | 0.0145 | 0.726 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
| mean | total | fraction |
|---|---|---|
| 5.75 | 223 | 0.996 |
theCharformulas <- attr(dc,"LatentCharFormulas")
finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| DecorFormula | caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | RAWAUC | fscores | |
|---|---|---|---|---|---|---|---|---|---|
| La_V_1048 | - (9.70e-03)V_1300 - (0.413)V_1064 + V_1048 - (0.599)V_1032 | 3.02e-04 | 4.30e-03 | -3.99e-03 | 3.15e-03 | 0.8394 | 0.841 | 0.545 | 2 |
| La_V_1226 | + (0.046)V_1300 - (1.034)V_1228 + V_1226 | 1.27e-03 | 1.55e-03 | 2.82e-03 | 1.49e-03 | 0.8181 | 0.803 | 0.546 | 1 |
| La_V_902 | - (1.21e-04)V_1300 + (0.417)V_906 - (1.213)V_904 + V_902 - (0.471)V_896 + (0.271)V_894 - (3.14e-03)V_868 | -2.20e-06 | 1.72e-05 | -2.01e-05 | 2.28e-05 | 0.6481 | 0.772 | 0.594 | -6 |
| La_V_1110 | - (0.123)V_1300 + V_1110 - (0.840)V_1064 | 4.48e-03 | 1.90e-02 | 1.95e-02 | 1.21e-02 | 0.1718 | 0.765 | 0.561 | 14 |
| La_V_1196 | + (6.26e-03)V_1300 - (0.191)V_1206 + V_1196 - (0.813)V_1194 | 5.71e-05 | 2.44e-04 | 2.81e-04 | 3.86e-04 | 0.2432 | 0.749 | 0.567 | 5 |
| La_V_1034 | + (8.11e-03)V_1300 - (0.034)V_1064 + V_1034 - (0.979)V_1032 | 2.35e-04 | 1.19e-03 | -6.05e-04 | 5.33e-04 | 0.9599 | 0.742 | 0.546 | 6 |
| La_V_848 | - (0.011)V_1300 + (1.038)V_868 - (2.013)V_860 + V_848 | 2.51e-04 | 2.17e-03 | -6.34e-04 | 9.82e-04 | 0.1939 | 0.734 | 0.589 | -3 |
| La_V_1032 | + (0.017)V_1300 + (1.769)V_1064 - (2.723)V_1056 + V_1032 | 3.10e-03 | 9.45e-03 | 9.68e-03 | 7.58e-03 | 0.9605 | 0.733 | 0.548 | 13 |
| La_V_892 | - (3.94e-05)V_1300 + (0.152)V_896 - (0.620)V_894 + V_892 - (0.762)V_890 + (0.231)V_888 - (1.47e-03)V_868 | -5.57e-06 | 4.67e-06 | -1.94e-06 | 5.19e-06 | 0.9945 | 0.732 | 0.596 | -5 |
| La_V_1252 | - (1.045)V_1300 + V_1252 | -5.51e-03 | 8.34e-03 | -1.32e-02 | 1.29e-02 | 0.0145 | 0.726 | 0.538 | 13 |
| V_908 | NA | 2.21e-01 | 1.28e-01 | 2.61e-01 | 1.17e-01 | 0.5785 | 0.596 | 0.596 | NA |
| V_906 | NA | 2.20e-01 | 1.27e-01 | 2.61e-01 | 1.17e-01 | 0.5848 | 0.596 | 0.596 | NA |
| V_904 | NA | 2.20e-01 | 1.27e-01 | 2.61e-01 | 1.17e-01 | 0.5918 | 0.596 | 0.596 | NA |
| V_892 | NA | 2.19e-01 | 1.27e-01 | 2.61e-01 | 1.21e-01 | 0.6256 | 0.596 | 0.596 | NA |
| V_890 | NA | 2.19e-01 | 1.27e-01 | 2.61e-01 | 1.21e-01 | 0.6163 | 0.596 | 0.596 | NA |
| V_888 | NA | 2.19e-01 | 1.27e-01 | 2.61e-01 | 1.22e-01 | 0.6032 | 0.596 | 0.596 | NA |
| V_912 | NA | 2.23e-01 | 1.29e-01 | 2.63e-01 | 1.17e-01 | 0.6041 | 0.595 | 0.595 | NA |
| V_910 | NA | 2.22e-01 | 1.28e-01 | 2.62e-01 | 1.17e-01 | 0.5866 | 0.595 | 0.595 | NA |
| V_896 | NA | 2.20e-01 | 1.27e-01 | 2.61e-01 | 1.20e-01 | 0.6202 | 0.595 | 0.595 | NA |
| V_894 | NA | 2.19e-01 | 1.27e-01 | 2.61e-01 | 1.21e-01 | 0.6248 | 0.595 | 0.595 | NA |
featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE) #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous])
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)
#pander::pander(pc$rotation)
PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])
gplots::heatmap.2(abs(PCACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "PCA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
EFAdataframe <- dataframeScaled
if (length(iscontinous) < 2000)
{
topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)/2)
if (topred < 2) topred <- 2
uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE) # EFA analysis
predEFA <- predict(uls,dataframeScaled[,iscontinous])
EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous])
EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
gplots::heatmap.2(abs(EFACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "EFA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
}
par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(rawmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
}
pander::pander(table(dataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 30 | 0 |
| 1 | 17 | 14 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.721 | 0.592 | 0.829 |
| 3 | se | 0.452 | 0.273 | 0.640 |
| 4 | sp | 1.000 | 0.884 | 1.000 |
| 6 | diag.or | Inf | NA | Inf |
par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe,control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(IDeAmodel,main="IDeA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(IDeAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
}
pander::pander(table(DEdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 26 | 4 |
| 1 | 1 | 30 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.918 | 0.819 | 0.973 |
| 3 | se | 0.968 | 0.833 | 0.999 |
| 4 | sp | 0.867 | 0.693 | 0.962 |
| 6 | diag.or | 195.000 | 20.484 | 1856.331 |
par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(PCAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}
pander::pander(table(PCAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 23 | 7 |
| 1 | 3 | 28 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.836 | 0.719 | 0.918 |
| 3 | se | 0.903 | 0.742 | 0.980 |
| 4 | sp | 0.767 | 0.577 | 0.901 |
| 6 | diag.or | 30.667 | 7.117 | 132.134 |
par(op)
EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(EFAmodel,EFAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(EFAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
}
pander::pander(table(EFAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 29 | 1 |
| 1 | 16 | 15 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.721 | 0.592 | 0.829 |
| 3 | se | 0.484 | 0.302 | 0.669 |
| 4 | sp | 0.967 | 0.828 | 0.999 |
| 6 | diag.or | 27.188 | 3.282 | 225.207 |
par(op)